package com.niit.musicserve.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 定位各种文件的地址
 */
@Configuration
public class FileConfig implements WebMvcConfigurer {
	
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		
		// 歌手图片映射
		registry.addResourceHandler("/img/singerPic/**")
			.addResourceLocations("file:" + System.getProperty("user.dir") + "/res/img/singerPic/");
		
		// 歌曲图片映射
		registry.addResourceHandler("/img/songPic/**")
			.addResourceLocations("file:" + System.getProperty("user.dir") + "/res/img/songPic/");
		
		// 歌曲文件映射
		registry.addResourceHandler("/res/song/**")
			.addResourceLocations("file:" + System.getProperty("user.dir") + "/res/song/");
		
		// 榜单图片映射
		registry.addResourceHandler("/img/rankPic/**")
			.addResourceLocations("file:" + System.getProperty("user.dir") + "/res/img/rankPic/");
		
		// 用户头像映射
		registry.addResourceHandler("/img/consumerPic/**")
			.addResourceLocations("file:" + System.getProperty("user.dir") + "/res/img/consumerPic/");
		
		// 专辑图片映射
		registry.addResourceHandler("/img/albumPic/**")
			.addResourceLocations("file:" + System.getProperty("user.dir") + "/res/img/albumPic/");
	}
}
